/**
 * @author kevinlaizhiyu@foxmail.com
 * @description user model
 * @date 2024-6-6
 * @version 1.0.0
 */

import mongoose, { Schema } from "mongoose";

const { ObjectId } = mongoose.Types;

export interface ICourt {
  courtId: string;
  courtName: string;
  courtType: string;
  status: boolean;
  capacity: number;
  manager: string;
  venueId: string;
  comment: string;
  createdAt: number;
  updatedAt: number;
}

const courtSchema = new Schema({
  courtId: {
    type: String,
    default: () => new ObjectId(),
    index: true,
    unique: true,
  },
  courtName: { type: String, required: true },
  courtType: { type: String, required: true },
  status: { type: Boolean, default: true },
  capacity: { type: Number, default: 0 },
  manager: { type: String, default: "" },
  comment: { type: String, default: "" },
  venueId: { type: String, default: "" },
  createdAt: { type: Number, default: Date.now },
  updatedAt: { type: Number, default: Date.now },
});

const CourtsModel = mongoose.model<ICourt>("courts", courtSchema);

export default CourtsModel;
